<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="format-detection" content="telephone=no">
<title></title>
<link href="wx_assets/css/store.css?v=2013-11-22" rel="stylesheet"
	type="text/css">
<script type="text/javascript">
var hrefParamsArray = GetParamsFromHref(window.location.search);

function GetParamsFromHref(search){
	var args = search.substring(1); 
　　	var retval = new Array(); 
	args = args.split("&"); 
		for(var i = 0; i < args.length; i ++){ 
			str = args[i]; 
			var arg = str.split("="); 
			if(arg.length <= 1) {
				continue; 
			}
			if(arg[0] == 'params') {
				var params = decodeURIComponent(arg[1]);
				var obj = eval('(' + params + ')');
				retval["start"] = obj.start;
				retval["id"] = obj.id;
				retval["districtCategoryId"] = obj.districtCategoryId;
			} else if(arg[0] == 'customerId') {
				retval["customerId"] = arg[1]; 
			}else if(arg[0] == 'userName'){
				retval["userName"] = arg[1]; 
			} 
		} 
		if (retval["id"] == undefined) {
			retval["id"] = 1;
		}
		if (retval["start"] == undefined) {
			retval["start"] = 0;
		}
		return retval; 
}
var limit = 10;
var pageCount = Math.ceil({$districtsTotal} / limit);
var page = Math.ceil(hrefParamsArray["start"] / limit) + 1;
</script>
</head>
<body id="page">
	<div class="header">
		<span class="top">{$name}</span>
	</div>
	<div id = "page_order">
	
	<present name="districts">
	<section class="normal">
	<ul>
		<volist name="districts" id="district">
		<li>
			<a href='javascript:void(0)' onclick="getDetail('{$district.leaf}', {$district.id}, '{$district.name}')">
			<span class='title'>{$district.name}</span>
			<span class='arrow'></span></a>
			</script>
		</li>
		</volist>
	</ul>
	</section>
	</present>
	</div>
	
	<div class="pagination" id="pagination">
		<div id="pagePrev">
		<script>
			var pid = '{$pId}';
			if(pid == ''){
				
			}
			if (page != 1) {
			var baseUrl =  '{$Think.config.SERVER_HOST}';
			var start = parseInt(hrefParamsArray["start"]) - limit;
			var urlString = baseUrl + 'call.html?customerId='+ hrefParamsArray["customerId"]+'&userName='+hrefParamsArray["userName"]
			+ "&module=store&method=getStoreDistrict&params={\"id\":" + pid + ",\"districtCategoryId\":"+hrefParamsArray["districtCategoryId"] + ",\"start\":" + start + "}";
			document.write("<a href='" + urlString + "'>上一页</a>");
		} else {
			document.write("<a href='javascript:void(0)' style='background:none;border:1px solid #cbcbcb;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;color:A4A3A3;cursor: default;'>上一页</a>");
		}
		</script>
		</div>
		<div class="allpage">
			<div class="currentpage"><script>document.write(page + "/" + pageCount);</script></div>
		</div>
		<div id="pageNext">
		<script>
			var pid = '{$pId}';
			if(pid == ''){
				
			}
				
			if (page != pageCount) {
			var baseUrl =  '{$Think.config.SERVER_HOST}';
			var start = parseInt(hrefParamsArray["start"]) + limit;
			var urlString = baseUrl + 'call.html?customerId='+ hrefParamsArray["customerId"]+'&userName='+hrefParamsArray["userName"]
			+ "&module=store&method=getStoreDistrict&params={\"id\":" + pid  + ",\"districtCategoryId\":"+hrefParamsArray["districtCategoryId"] + ",\"start\":" + start + "}";
			document.write("<a href='" + urlString + "'>下一页</a>");
		} else {
			document.write("<a href='javascript:void(0)' style='background:none;border:1px solid #cbcbcb;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;color:A4A3A3;cursor: default;'>下一页</a>");
		}
		</script>
		</div>
	</div>
<script>

	if(pageCount == 1 && page == pageCount){
		document.getElementById("pagination").style.display="none";
	}

	function getDetail(leaf, id, name) {
		var baseUrl =  '{$Think.config.SERVER_HOST}';
		var urlString = baseUrl + 'call.html?customerId='+ hrefParamsArray["customerId"]+'&userName='+hrefParamsArray["userName"]
			+ "&module=store"; 
		
		if (leaf == 0) {
			urlString += "&method=getStoreDistrict&params={\"id\":" + id + ",\"districtCategoryId\":"+hrefParamsArray["districtCategoryId"]+"}";
		} else {
			urlString += "&method=getStoreList&params={\"id\":" + id+ "}#mp.weixin.qq.com";
		}
		location.href= urlString;
	}
</script>
</body>